{extend name="public/base" /}
{block name="content"}

<style>
    .formDiv{
        height: 100%;
    }
    .blank{
        margin-bottom: 10%;
    }
    .el-pager li{
        font-size: 19px;
    }

</style>

<div class="formDiv">

    <h3>创建类别</h3>
    <div style="display:inline;">
        <input type="text" id="classType" style="width: 60%;float: left" class="el-input__inner blank" name="classType" placeholder="请输入类别名称"/>
        <input type="button" id="classSubmit" style="width: 20%;float: left;margin-left: 5%;" class="el-button el-button--primary"
           value="提交"/>
    </div>

    <table class="el-table__body" style="width: 820px;border: 5px;margin-bottom: 10%;">
        <thead>
        <tr class="el-table_row">
            <th>ID</th>
            <th>类别名称</th>
            <th>创建时间</th>
        </tr>
        </thead>
        <tbody>
        <?php if(sizeof($classData) == 0){ ?>
        <tr>
            <td colspan="3" style="text-align: center;font-weight: bold">
                暂时没有数据
            </td>
        </tr>
        <?php }else{ ?>
        <?php foreach($classData as $k => $v){ ?>
        <?php if($k%2 == 0){ ?>
        <tr class="el-table__row" style="background-color: #FDF5E6">
            <td class="el-table_1_column_10">
                <?php echo $v['id']; ?>
            </td>
            <td class="el-table_1_column_10">
                <?php echo $v['classname']; ?>
            </td>
            <td class="el-table_1_column_10">
                <?php echo date('Y-m-d',$v['add_time']); ?>
            </td>
            <td class="el-table_1_column_10">
                <button onclick="delClass(<?php echo $v['id']; ?>)" type="button" class="el-button el-button--primary" value="删除">
                    <i class="el-icon-delete">
                    </i>
                </button>
            </td>
        </tr>
        <?php }else{ ?>
        <tr class="el-table__row el-table__row">
            <td class="el-table_1_column_10">
                <?php echo $v['id']; ?>
            </td>
            <td class="el-table_1_column_10">
                <?php echo $v['classname']; ?>
            </td>
            <td class="el-table_1_column_10">
                <?php echo date('Y-m-d',$v['add_time']); ?>
            </td>
            <td class="el-table_1_column_10">
                <button onclick="delClass(<?php echo $v['id']; ?>)" type="button" class="el-button el-button--primary" value="删除">
                    <i class="el-icon-delete">
                    </i>
                </button>
            </td>
        </tr>
        <?php } ?>
        <?php } ?>
        <?php } ?>
        </tbody>
    </table>
    <p/>
    <div style="width: 100%;color: red;">目前类别菜单最好保持5个以下</div>
    <script src="/static/index/js/newsClass.js" type="text/javascript"></script>
    <script type="text/javascript">
        function delClass(id){
            if(confirm("确定执行删除？")) {
                $.post("/index.php/index/Index/_delClassName", {id: id}, function (msg) {

                    var msgArr = JSON.parse(msg);
                    var status = msgArr.status;
                    if (status == 1) {
                        alert(msgArr.msg);
                        location.href = "/index.php/index/Index/newstitle";
                        return;
                    } else {
                        alert(msgArr.msg);
                        return;
                    }
                });
            }
        }
    </script>
</div>

{/block}